<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: languages.php 61 2013-09-21 11:59:04Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 61 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:59:04 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

switch ($_GET['action']) {
	case 'insert':
		$name = $_POST['name'];
		$code = $_POST['code'];
		$image = $_POST['image'];
		$directory = $_POST['directory'];

		if(empty($_POST['sort_order'])) {
			$check_sort_order = $db->db_query("SELECT sort_order FROM ". TABLE_LANGUAGES ." ORDER BY sort_order DESC LIMIT 1");
			$sort_order = $check_sort_order->fields['sort_order']+1;
		} else
			$sort_order = $_POST['sort_order'];

		$charset = $_POST['charset'];
		$status = $_POST['status'];
		$status_admin = $_POST['status_admin'];

      	$db->db_query("INSERT
      						INTO ".TABLE_LANGUAGES."
      							(name, code, image, directory, sort_order, language_charset, status, status_admin)
      						VALUES
      							(".$db->db_prepare($name).", ".$db->db_prepare($code).", ".$db->db_prepare($image).", ".$db->db_prepare($directory).", ".$db->db_prepare($sort_order).", ".$db->db_prepare($charset).", ".$db->db_prepare($status).", ".$db->db_prepare($status_admin).")");
	      $insert_id = $db->db_insert_id();

	    $categories = $db->db_query("SELECT
											c.categories_id,
											cd.categories_name
										FROM
											".TABLE_CATEGORIES." c
										LEFT JOIN
											".TABLE_CATEGORIES_DESCRIPTION." cd ON c.categories_id = cd.categories_id
										WHERE
											cd.language_id = '".$_SESSION['languages_id']."'");
	    while(!$categories->EOF) {
	        $db->db_query("INSERT INTO
	        					".TABLE_CATEGORIES_DESCRIPTION." (categories_id, language_id, categories_name)
	        				VALUES
	        					('".$categories->fields['categories_id']."', '".$insert_id."', ".$db->db_prepare($categories->fields['categories_name']).")");
	        $categories->MoveNext();
	    }
		
		/**
			Blog Kategorie
		*/
		$blog_cat = $db->db_query("SELECT 
										categories_id,
										titel
									FROM
									 	".TABLE_BLOG_CATEGORIES."
									WHERE
									 	language_id = '".$_SESSION['languages_id']."' ");
		if($blog_cat->_numOfRows) {		
			while(!$blog_cat->EOF) {
				$db->db_query("INSERT INTO ".TABLE_BLOG_CATEGORIES." 
									(categories_id,language_id,titel,status, date) 
								VALUES 
									('".$blog_cat->fields['categories_id']."','".$insert_id."', '".$blog_cat->fields['titel']."', '1','NOW()')");
				$blog_cat->MoveNext();
			}
		}
		
		/**
			Blog Items
		*/
		$blog_item = $db->db_query("SELECT 
										item_id,
										title,
										categories_id
									FROM
									 	".TABLE_BLOG_ITEMS."
									 WHERE
									 	language_id = '".$_SESSION['languages_id']."'");
		if($blog_item->_numOfRows) {		
			while(!$blog_item->EOF) {
				$db->db_query("INSERT INTO ".TABLE_BLOG_ITEMS." 
									(item_id,categories_id,language_id,status,date) 
								VALUES 
									('".$blog_item->fields['item_id']."','".$blog_item->fields['categories_id']."', '".$blog_item->fields['title']."', '".$insert_id."', '1','NOW()')");
				$blog_item->MoveNext();
			}
		}
	    /**
	     * Produkte
	     */
	    $products = $db->db_query("SELECT
    									p.products_id,
    									pd.products_name,
    									pd.products_description,
    									pd.products_url
    								FROM
    									".TABLE_PRODUCTS." p
    								LEFT JOIN
    									".TABLE_PRODUCTS_DESCRIPTION." pd ON p.products_id = pd.products_id
    								WHERE
    									pd.language_id = '".$_SESSION['languages_id']."'");
	    while(!$products->EOF) {
	        $db->db_query("INSERT INTO
	        					".TABLE_PRODUCTS_DESCRIPTION."
	        						(products_id, language_id, products_name, products_description, products_url)
	        				VALUES
	        					('".$products->fields['products_id']."', '".$insert_id."', ".$db->db_prepare($products->fields['products_name']).", ".$db->db_prepare($products->fields['products_description']).", ".$db->db_prepare($products->fields['products_url']).")");
	        $products->MoveNext();
	    }

		$db->db_query("ALTER TABLE ".TABLE_PRODUCTS_IMAGES." ADD alt_langID_".$insert_id." VARCHAR(64) NOT NULL");
		$db->db_query("ALTER TABLE ".TABLE_ADMIN_MENU." ADD title_language_id_".$insert_id." VARCHAR(64) NOT NULL");

	      /**
	       * Produkt Optionen
	       */

		$products_options = $db->db_query("SELECT
												products_options_id,
												products_options_name
											FROM
												".TABLE_PRODUCTS_OPTIONS."
											WHERE
												language_id = '".$_SESSION['languages_id']."'");
		while(!$products_options->EOF) {
			$db->db_query("INSERT INTO
								".TABLE_PRODUCTS_OPTIONS."
								(products_options_id, language_id, products_options_name)
							VALUES
								('".$products_options->fields['products_options_id']."', '".$insert_id."', ".$db->db_prepare($products_options->fields['products_options_name']).")");
			$products_options->MoveNext();
		}

		/**
		 * Produkt Option Value
		 */
		$products_options_values = $db->db_query("SELECT
														products_options_values_id,
														products_options_values_name
													FROM
														".TABLE_PRODUCTS_OPTIONS_VALUES."
													WHERE
														language_id = '".$_SESSION['languages_id']."'");
		while(!$products_options_values->EOF) {
			$db->db_query("INSERT INTO
								".TABLE_PRODUCTS_OPTIONS_VALUES."
								(products_options_values_id, language_id, products_options_values_name)
							VALUES
								('".$products_options_values->fields['products_options_values_id']."', '".$insert_id."', ".$db->db_prepare($products_options_values->fields['products_options_values_name']).")");
			$products_options_values->MoveNext();
		}

	    /**
	     * Bestell Status
	     */
		$orders_status = $db->db_query("SELECT
											orders_status_id,
											orders_status_name
										FROM
											".TABLE_ORDERS_STATUS."
										WHERE
											language_id = '".$_SESSION['languages_id']."'");
		while(!$orders_status->EOF) {
			$db->db_query("INSERT INTO
								".TABLE_ORDERS_STATUS."
									(orders_status_id, language_id, orders_status_name)
							VALUES
								('".$orders_status->fields['orders_status_id']."', '".$insert_id."', ".$db->db_prepare($orders_status->fields['orders_status_name']).")");
			$orders_status->MoveNext();
		}

	    /**
	     * Lieferstatus
	     */
		$shipping_status = $db->db_query("SELECT
												shipping_status_id,
												shipping_status_name
											FROM
												".TABLE_SHIPPING_STATUS."
											WHERE
												language_id = '".$_SESSION['languages_id']."'");
		while(!$shipping_status->EOF) {
			$db->db_query("INSERT INTO
								".TABLE_SHIPPING_STATUS." 
									(shipping_status_id, language_id, shipping_status_name)
							VALUES
								('".$shipping_status->fields['shipping_status_id']."', '".$insert_id."', ".$db->db_prepare($shipping_status->fields['shipping_status_name']).")");
			$shipping_status->MoveNext();
		}

	    /**
	     * Crossselling Gruppen
	     */
		$xsell_grp = $db->db_query("SELECT
										products_xsell_grp_name_id,
										xsell_sort_order,
										groupname
									FROM
										".TABLE_PRODUCTS_XSELL_GROUPS."
									WHERE
										language_id = '".$_SESSION['languages_id']."'");
		while(!$xsell_grp->EOF) {
			$db->db_query("INSERT INTO
								".TABLE_PRODUCTS_XSELL_GROUPS."
								(products_xsell_grp_name_id,xsell_sort_order, language_id, groupname)
							VALUES
								('".$xsell_grp->fields['products_xsell_grp_name_id']."', '".$xsell_grp->fields['xsell_sort_order']."', '".$insert_id."', ".$db->db_prepare($xsell_grp->fields['groupname']).")");
			$xsell_grp->MoveNext();
		}

		/**
		 * Kundenstatus
		 */
		$customers_status = $db->db_query("SELECT customers_status_id FROM ".TABLE_CUSTOMERS_STATUS);
		while(!$customers_status->EOF) {
			$group_data = $db->db_query("SELECT * FROM ".TABLE_CUSTOMERS_STATUS." WHERE customers_status_id='".$customers_status->fields['customers_status_id']."'");

			$c_data = array('customers_status_id' 					=>	$customers_status->fields['customers_status_id'],
							'language_id' 							=> 	$insert_id,
							'customers_status_name'					=>	$group_data->fields['customers_status_name'],
							'customers_status_public'				=>	$group_data->fields['customers_status_public'],
							'customers_status_image'				=>	$group_data->fields['customers_status_image'],
							'customers_status_discount'				=>	$group_data->fields['customers_status_discount'],
							'customers_status_ot_discount_flag'		=>	$group_data->fields['customers_status_ot_discount_flag'],
							'customers_status_ot_discount'			=>	$group_data->fields['customers_status_ot_discount'],
							'customers_status_graduated_prices'		=>	$group_data->fields['customers_status_graduated_prices'],
							'customers_status_show_price'			=>	$group_data->fields['customers_status_show_price'],
							'customers_status_show_price_tax'		=>	$group_data->fields['customers_status_show_price_tax'],
							'customers_status_add_tax_ot'			=>	$group_data->fields['customers_status_add_tax_ot'],
							'customers_status_payment_unallowed'	=>	$group_data->fields['customers_status_payment_unallowed'],
							'customers_status_shipping_unallowed'	=>	$group_data->fields['customers_status_shipping_unallowed'],
							'customers_status_discount_attributes'	=>	$group_data->fields['customers_status_discount_attributes']);

			$db->db_perform(TABLE_CUSTOMERS_STATUS, $c_data);
			$customers_status->MoveNext();
		}
		require_once(DIR_FS_INC.'inc.sql_query.php');
		if(file_exists(DIR_FS_CATALOG.'lang/'.$_POST['directory'].'/'.$_POST['directory'].'.sql'))
			sql_query(DIR_FS_CATALOG.'lang/'.$_POST['directory'].'/'.$_POST['directory'].'.sql', $insert_id);
		
		if(file_exists(DIR_FS_CATALOG.'lang/'.$_POST['directory'].'/'.$_POST['directory'].'_variables.sql.php'))
			include(DIR_FS_CATALOG.'lang/'.$_POST['directory'].'/'.$_POST['directory'].'_variables.sql.php');
		
		if ($_POST['default'] == 'on')
			$db->db_query("UPDATE ".TABLE_CONFIGURATION." SET configuration_value = ".$db->db_prepare($code)." WHERE configuration_key = 'DEFAULT_LANGUAGE'");
		
		if(MODULE_SEO_URL_INDEX_STATUS == 'True') {
		   	require_once(DIR_FS_INC.'inc.seo_url.php');
		 	!$seo_url ? $seo_url = new SeoUrl() : false;
		 	$seo_url->createSeoDBTable();
		}
		
      	redirect(href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$insert_id.'&new=1'));
	break;

    case 'save':
		$lID = $_GET['lID'];
		$name = $_POST['name'];
		$code = $_POST['code'];
		$image = $_POST['image'];
		$directory = $_POST['directory'];
		$sort_order = $_POST['sort_order'];
		$charset = $_POST['charset'];
		$status = $_POST['status'];
		$status_admin = $_POST['status_admin'];

		$db->db_query("UPDATE
							".TABLE_LANGUAGES."
						SET
							name = ".$db->db_prepare($name).",
							code = ".$db->db_prepare($code).",
							image = ".$db->db_prepare($image).",
							directory = ".$db->db_prepare($directory).",
							sort_order = ".$db->db_prepare($sort_order).",
							language_charset = ".$db->db_prepare($charset).",
							status = ".$db->db_prepare($status).",
							status_admin = ".$db->db_prepare($status_admin)."
						WHERE
							languages_id = ".$db->db_prepare($lID)."");

		if ($_POST['default'] == 'on')
			$db->db_query("UPDATE ".TABLE_CONFIGURATION." SET configuration_value = ".$db->db_prepare($code)." WHERE configuration_key = 'DEFAULT_LANGUAGE'");

		redirect(href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$_GET['lID']));
	break;

    case 'deleteconfirm':
		$lID = $_GET['lID'];
		
		if($lID != $_SESSION['languages_id']) {
			$lng = $db->db_query("SELECT languages_id FROM ".TABLE_LANGUAGES." WHERE code = '".DEFAULT_CURRENCY."'");
			if ($lng->fields['languages_id'] == $lID)
				$db->db_query("UPDATE ".TABLE_CONFIGURATION." SET configuration_value = '' WHERE configuration_key = 'DEFAULT_CURRENCY'");
	
			$db->db_query("DELETE FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_PRODUCTS_OPTIONS." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_PRODUCTS_OPTIONS_VALUES." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_BRAND_INFO." WHERE languages_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_ORDERS_STATUS." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_SHIPPING_STATUS." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_LANGUAGES." WHERE languages_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_CONTENT_MANAGER." WHERE languages_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_PRODUCTS_CONTENT." WHERE languages_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_CUSTOMERS_STATUS." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_PERSONAL_LINKS_URL." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_BLOG_CATEGORIES." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_BLOG_ITEMS." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_EMAILS." WHERE languages_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_NEWS_TICKER." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("DELETE FROM ".TABLE_SEO_URL." WHERE language_id = ".$db->db_prepare($lID));
			$db->db_query("ALTER TABLE ".TABLE_PRODUCTS_IMAGES." DROP COLUMN alt_langID_".$lID);
			$db->db_query("ALTER TABLE ".TABLE_ADMIN_MENU." DROP COLUMN title_language_id_".$lID);
			$db->db_query("DROP TABLE ".DB_PREFIX."language_".$lID);
			
		} else
			$message_stack->add(LANGUAGE_IS_ACTIVE, 'error');
			
		redirect(href_link(FILENAME_LANGUAGES, 'page='.$_GET['page']));
	break;

    case 'delete':
		$lID = $_GET['lID'];

		$lng = $db->db_query("SELECT code FROM ".TABLE_LANGUAGES." WHERE languages_id = '".$lID."'");

		$remove_language = true;
		if ($lng->fields['code'] == DEFAULT_LANGUAGE) {
			$remove_language = false;
			$message_stack->add(ERROR_REMOVE_DEFAULT_LANGUAGE, 'error');
		}
	break;
}

$lang_array = array();
$check = $db->db_query("SELECT code FROM ".TABLE_LANGUAGES."");
while(!$check->EOF) {
	array_push($lang_array, $check->fields['code']);
	$check->MoveNext();
}

require(DIR_WS_INCLUDES.'metatag.php'); ?>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
<table class="outerTable" cellspacing="0" cellpadding="0">
  <tr>
    <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
		<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
	</td>
    <td class="boxCenter" valign="top">
		<table width="100%" cellspacing="0" cellpadding="2">
      		<tr>
        		<td width="100%">
					<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
			   			<tr>
			     			<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
						</tr>
					</table>
				</td>
      		</tr>
			<?php if(!isset($_GET['action'])) { ?>
			<tr>
				<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td class="main" align="left">
								Welche Sprache soll installiert werden?
							</td>
							<td class="main">
								<?php
									if(!in_array('en',$lang_array,true)) {
										echo draw_form('languages', FILENAME_LANGUAGES, 'action=insert');
										echo draw_hidden_field('name','English').
											draw_hidden_field('status','0').
											draw_hidden_field('code','en').
											draw_hidden_field('charset','utf-8').
											draw_hidden_field('image','en.gif').
											draw_hidden_field('status_admin','1').
											draw_hidden_field('directory','english');
										echo '<button class="button" type="submit">Englisch</button>'."\n".'</form>';
									} else echo '&nbsp;';
								?>
							</td>
							<td class="main" align="right">
								Hinweis: <a href="#" onclick="javascript:return false;" <?php echo mouseOverJS(HEAD_EXTRA_LANGUAGES,BODY_EXTRA_LANGUAGES); ?>><?php echo image(DIR_WS_ICONS.'icon_help.gif'); ?></a>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<?php } ?>
      		<tr>
        		<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
          				<tr>
            				<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">
              					<tr class="dataTableHeadingRow">
                					<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_NAME; ?></td>
                					<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_CODE; ?></td>
									<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_STATUS; ?></td>
									<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_STATUS_ADMIN; ?></td>
                					<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              					</tr>
								<?php
								  $languages = $db->db_query("SELECT 
								  									languages_id, 
								  									name, 
								  									code, 
								  									image, 
								  									directory, 
								  									sort_order, 
								  									language_charset, 
								  									status, 
								  									status_admin 
								  								FROM 
								  									".TABLE_LANGUAGES." 
								  								ORDER BY 
								  									sort_order");

								  while(!$languages->EOF) { $rows++;
								    if (((!$_GET['lID']) || (@$_GET['lID'] == $languages->fields['languages_id'])) && (!$lInfo) && (substr($_GET['action'], 0, 3) != 'new')) {
								      $lInfo = new objectInfo($languages->fields);
								    }

								    if ( (is_object($lInfo)) && ($languages->fields['languages_id'] == $lInfo->languages_id) ) {
								      echo '<tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'pointer\'" onclick="document.location.href=\''.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=edit').'\'">'."\n";
								    } else {
										if ($rows % 2 == 0)
								    		$f = 'dataTableRow';
								    	else
								    		$f = '';
								      echo '<tr class="'.$f.'" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'pointer\'" onmouseout="this.className=\''.$f.'\'" onclick="document.location.href=\''.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$languages->fields['languages_id']).'\'">'."\n";
								    }
								    if (DEFAULT_LANGUAGE == $languages->fields['code'])
								      echo '<td class="dataTableContent"><b>'.$languages->fields['name'].' ('.TEXT_DEFAULT.')</b></td>'."\n";
								    else
								      echo '<td class="dataTableContent">'.$languages->fields['name'].'</td>'."\n";
								    
								?>
                				<td class="dataTableContent"><?php echo $languages->fields['code']; ?></td>
								<?php
									if($languages->fields['status'] == '1')
										echo '<td class="dataTableContent">'.TEXT_LANGUAGE_ACTIVE.'</td>';
									else
										echo '<td class="dataTableContent">'.TEXT_LANGUAGE_INACTIVE.'</td>';

									if($languages->fields['status_admin'] == '1')
										echo '<td class="dataTableContent">'.TEXT_LANGUAGE_ACTIVE.'</td>';
									else
										echo '<td class="dataTableContent">'.TEXT_LANGUAGE_INACTIVE.'</td>';
								?>
                				<td class="dataTableContent" align="right">
								<?php
									if ( (is_object($lInfo)) && ($languages->fields['languages_id'] == $lInfo->languages_id) ) {
										echo image(DIR_WS_IMAGES.'icon_arrow_right.gif');
									} else {
										echo '<a href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$languages->fields['languages_id']).'">'.image(DIR_WS_IMAGES.'icon_info.gif', IMAGE_ICON_INFO).'</a>';
									}
								?>
								</td>
								<?php
									$languages->MoveNext();
								  }
								?>
            				</table>
							
							<?php if(!$_GET['action']) { ?>
							<table>
				  				<tr>
                    				<td align="right" colspan="2"><?php echo '<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=new').'">'.BUTTON_NEW_LANGUAGE.'</a>'; ?></td>
                  				</tr>
							</table>
							<?php }	?>
						</td>
						<?php
						  $direction_options = array( array('id' => '', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_DEFAULT),
						                              array('id' => 'ltr', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_LEFT_TO_RIGHT),
						                              array('id' => 'rtl', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_RIGHT_TO_LEFT));

						  $heading = array();
						  $contents = array();
						  switch ($_GET['action']) {
						    case 'new':
						      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_NEW_LANGUAGE.'</b>');

						      $contents = array('form' => draw_form('languages', FILENAME_LANGUAGES, 'action=insert'));
						      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_NAME.'<br />'.draw_input_field('name'));
							  $contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_NAME.':<br />'.draw_radio_field('status',1,true).' '.TEXT_LANGUAGE_ACTIVE. ' <br />'.draw_radio_field('status',0,false).' '.TEXT_LANGUAGE_INACTIVE);
							  $contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_STATUS_ADMIN.':<br />'.draw_radio_field('status_admin',1,true).' '.TEXT_LANGUAGE_ACTIVE. ' <br />'.draw_radio_field('status_admin',0,false).' '.TEXT_LANGUAGE_INACTIVE);
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_CODE.'<br />'.draw_input_field('code'));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_CHARSET.'<br />'.draw_input_field('charset'));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_IMAGE.'<br />'.draw_input_field('image', 'icon.gif'));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_DIRECTORY.'<br />'.draw_input_field('directory'));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_SORT_ORDER.'<br />'.draw_input_field('sort_order'));
						      $contents[] = array('text' => '<br />'.draw_checkbox_field('default').' '.TEXT_SET_DEFAULT);
						      $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'.BUTTON_INSERT.'</button> <a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$_GET['lID']).'">'.BUTTON_CANCEL.'</a>');
						      break;

						    case 'edit':
						      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_EDIT_LANGUAGE.'</b>');

						      $contents = array('form' => draw_form('languages', FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=save'));
						      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_NAME.'<br />'.draw_input_field('name', $lInfo->name));
							  $contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_NAME.':<br />'.draw_radio_field('status','1',($lInfo->status==1)?true:false).' '.TEXT_LANGUAGE_ACTIVE. ' <br />'.draw_radio_field('status','0',($lInfo->status==0)?true:false).' '.TEXT_LANGUAGE_INACTIVE);
							$contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_STATUS_ADMIN.':<br />'.draw_radio_field('status_admin','1',($lInfo->status_admin==1)?true:false).' '.TEXT_LANGUAGE_ACTIVE. ' <br />'.draw_radio_field('status_admin','0',($lInfo->status_admin==0)?true:false).' '.TEXT_LANGUAGE_INACTIVE);
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_CODE.'<br />'.draw_input_field('code', $lInfo->code));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_CHARSET.'<br />'.draw_input_field('charset', $lInfo->language_charset));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_IMAGE.'<br />'.draw_input_field('image', $lInfo->image));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_DIRECTORY.'<br />'.draw_input_field('directory', $lInfo->directory));
						      $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_SORT_ORDER.'<br />'.draw_input_field('sort_order', $lInfo->sort_order));
						      if (DEFAULT_LANGUAGE != $lInfo->code) $contents[] = array('text' => '<br />'.draw_checkbox_field('default').' '.TEXT_SET_DEFAULT);
						      $contents[] = array('align' => 'center', 'text' => '<br /><button type="submit" class="button" onclick="this.blur();">'. BUTTON_UPDATE.'</button> <a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id).'">'.BUTTON_CANCEL.'</a>');
						      break;

						    case 'delete':
						      $heading[] = array('text' => '<b>'.TEXT_INFO_HEADING_DELETE_LANGUAGE.'</b>');

						      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
						      $contents[] = array('text' => '<br /><b>'.$lInfo->name.'</b>');
						      $contents[] = array('align' => 'center', 'text' => '<br />'.(($remove_language) ? '<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=deleteconfirm').'">'.BUTTON_DELETE.'</a>' : '').' <a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id).'">'.BUTTON_CANCEL.'</a>');
						      break;

						    default:
						      if (is_object($lInfo)) {
						        $heading[] = array('text' => '<b><strong>'.$lInfo->name.'</strong></b>');

						        $contents[] = array('align' => 'center', 'text' => '<a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=edit').'">'.BUTTON_EDIT.'</a> <a class="button" onClick="this.blur();" href="'.href_link(FILENAME_LANGUAGES, 'page='.$_GET['page'].'&lID='.$lInfo->languages_id.'&action=delete').'">'.BUTTON_DELETE.'</a>');
						        $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_NAME.' '.$lInfo->name);

								if($lInfo->status==1){
									$contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_NAME.': <b>'.TEXT_LANGUAGE_ACTIVE.'</b>');
								} else {
									$contents[] = array('text' => '<br />'.TABLE_HEADING_LANGUAGE_NAME.': <b>'.TEXT_LANGUAGE_INACTIVE.'</b>');
								}
								if($lInfo->status_admin==1){
									$contents[] = array('text' => TABLE_HEADING_LANGUAGE_STATUS_ADMIN.': <b>'.TEXT_LANGUAGE_ACTIVE.'</b>');
								} else {
									$contents[] = array('text' => TABLE_HEADING_LANGUAGE_STATUS_ADMIN.': <b>'.TEXT_LANGUAGE_INACTIVE.'</b>');
								}
						        $contents[] = array('text' => TEXT_INFO_LANGUAGE_CODE.' '.$lInfo->code);
						        $contents[] = array('text' => TEXT_INFO_LANGUAGE_CHARSET_INFO.' '.$lInfo->language_charset);
						        $contents[] = array('text' => 'Icon: '.image(DIR_WS_LANGUAGES.$lInfo->directory.'/'.$lInfo->image, $lInfo->name));
						        $contents[] = array('text' => TEXT_INFO_LANGUAGE_DIRECTORY.'<br />'.DIR_WS_LANGUAGES.'<b>'.$lInfo->directory.'</b>');
						        $contents[] = array('text' => '<br />'.TEXT_INFO_LANGUAGE_SORT_ORDER.' '.$lInfo->sort_order);
						      }
						      break;
						  }

						  if ( (not_null($heading)) && (not_null($contents)) ) {
						    echo '<td width="25%" class="border" valign="top">'."\n";

						    $box = new box;
						    echo $box->infoBox($heading, $contents);

						    echo '</td>'."\n";
						  }
						?>
          			</tr>
        		</table>
			</td>
      	</tr>
    </table>
	</td>
  </tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>